package com.yang.contentaudit.config;

import com.yang.contentaudit.service.ContentAuditService;
import com.yang.contentaudit.service.impl.BaiduContentAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: Billyang
 * @date: 2024/9/30 19:01
 */
@Configuration
@EnableConfigurationProperties({BaiduContentAuditProperties.class})
@ConditionalOnMissingBean(ContentAuditService.class)
public class ContentAuditAutoConfiguration {

   @Bean
   @ConditionalOnProperty(prefix = "baidu", name = "app-id")
  public BaiduContentAuditService baiduContentAuditService(BaiduContentAuditProperties properties){
      return new BaiduContentAuditService(properties.getAppId(), properties.getApiKey(), properties.getSecretKey());
  }
}
